package com.lzh.chatnote.user.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 *  1是 2否
 */
@AllArgsConstructor
@Getter
public enum YesOrNoEnum {
    YES(1, "是"),
    NO(0, "否"),
    ;
    private final Integer type;
    private final String describe;

    private static final Map<Integer, YesOrNoEnum> cache;

    static {
        cache = Arrays.stream(YesOrNoEnum.values()).collect(Collectors.toMap(YesOrNoEnum::getType, Function.identity()));
    }

    public static YesOrNoEnum of(Integer type) {
        return cache.get(type);
    }
}
